<?php defined('RUN_KATANA') or die('Restricted access'); ?>
	<table class="zebra com_list" cellspacing="0" cellpadding="0" border="0" style="width:100%;">
        <thead class="fields">
			<tr>
				<th class="first" style="text-align:center;">&nbsp;&nbsp;#&nbsp;&nbsp;</th>
				<th class="nowrap"><?php echo ucfirst($txt->getWord('file')); ?>&nbsp;&nbsp;</th>
				<th class="last"><?php echo ucfirst($txt->getWord('delete')); ?>&nbsp;&nbsp;</th>
			</tr>
		</thead>
		<tbody>
			<?php 
			if(is_array($adc->CurrentAd->getFiles()))
			{
				foreach($adc->CurrentAd->getFiles() as $file)
				{
					if($file->getId() > 0)
					{
					?>
					<tr class="items">
						<td class="first nowrap">&nbsp;&nbsp;<?php echo ($file->getFileOrder()+1); ?>&nbsp;&nbsp;<input type="hidden" name="img_id[]" value="<?php echo $file->getId(); ?>" /></td>
						<td class="left nowrap">
							<a target="_blank" href="<?php echo ADFILE_URL.$file->getFilename(); ?>"><?php echo $file->getTitle(); ?></a>&nbsp;&nbsp;
						</td>
						<td valign="middle" class="last"><img title="<?php echo ucfirst($txt->getWord('delete')); ?>" class="deleteFileButton icon command cat_delete" src="<?php echo SYSICONS_URL; ?>delete_16.gif" rel="<?php echo $file->getId(); ?>"  />&nbsp;&nbsp;</td>
					</tr>
					<?php 
					}
				}
			} ?>
		</tbody>
    </table>
	<input type="hidden" id="del_file_id" name="del_file_id" value="0" />
	<input type="hidden" id="up_file" name="up_file" value="0" />
	<input type="hidden" id="down_file" name="down_file" value="0" />
<script type="text/javascript">

$(function() {
	jQuery('#del_file_dialog').dialog({
		autoOpen: false,
		bgiframe: true,
		resizable: false,
		height:140,
		modal: true,
		overlay: 
		{
			backgroundColor: '#000',
			opacity: 0.5
		},
		buttons: 
		{
			'<?php echo ucfirst($txt->getWord('no')); ?>': function() 
			{
				jQuery('#del_file_id').val(0);
				jQuery(this).dialog('close');
			},
			'<?php echo ucfirst($txt->getWord('yes')); ?>': function() 
			{
				jQuery(this).dialog('close');
				jQuery('#<?php echo $com->getId(); ?>_editor_ad').submit();
			}
		}
	});
});

jQuery(".deleteFileButton").click(function() { deleteFileDialog($(this).attr('rel')); /* $( "#dialog-form" ).dialog( "open" );*/ });
function deleteFileDialog(itemId)
{
	jQuery('#del_file_id').val(itemId);
	jQuery('#del_file_dialog').dialog('open');
}


</script>
<div id="del_file_dialog" title="<?php echo ucfirst($txt->getWord('delete_file')); ?>?" style="display:none; text-align:left;">
	<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span><?php echo ucfirst($txt->getWord('sure_you_want_to_delete')); ?></p>
</div>